<template>
  <div>
    <ul class="mui-table-view mui-table-view-chevron">
      <li class="mui-table-view-cell mui-media" v-for="item in newslist" :key="item.id">
        <router-link class="mui-navigate-right" :to="'/home/newsinfo/'+item.id">
          <img class="mui-media-object mui-pull-left"
               :src="item.img">
          <div class="mui-media-body">
            <h3>{{ item.title }}</h3>
            <p class='mui-ellipsis'>
              <span>{{ item.time }}</span>
              <span>点击：{{ item.click }}次</span>
            </p>
          </div>
        </router-link>
      </li>
    </ul>
  </div>
</template>

<script>
import Toast from 'mint-ui'

export default {
  data () {
    return {
      newslist: []
    }
  },
  created () {
    this.getNewsList()
  },
  methods: {
    getNewsList () {
      this.$http.get('vuenewslist').then(result => {
        if (result.body) {
          // 成功了
          this.newslist = result.body
        } else {
          // 失败的
          Toast('加载新闻列表失败')
        }
      })
    }
  },
}
</script>

<style lang="scss" scoped>
.mui-table-view-chevron {
  li {
    h3 {
      font: 14px/14px "宋体";
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
    .mui-ellipsis {
      font-size: 12px;
      color: dodgerblue;
      display: flex;
      justify-content: space-between;
    }
  }
}
</style>
